package com.kzj.service.impl;

import com.kzj.domain.Academy;
import com.kzj.dao.AcademyDao;
import com.kzj.domain.Teacher;
import com.kzj.global.re.Result;
import com.kzj.global.utils.IdGeneratorUtil;
import com.kzj.global.utils.MatchesUtil;
import com.kzj.service.AcademyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kzj
 * @since 2023-12-01
 */
@Service
public class AcademyServiceImpl extends ServiceImpl<AcademyDao, Academy> implements AcademyService {

    @Override
    public Result addAcademy(Academy academy) {
        MatchesUtil.objMatches(academy);
        String id = IdGeneratorUtil.generatorId(Academy.class);
        System.out.println("id"+id);
        academy.setId(id);
        this.save(academy);
        return Result.success();
    }

    @Override
    public Result getAllAcademy() {
        List<Academy> list =this.list();
        return Result.success(list);
    }

    @Override
    public Result getAcademyById(String id) {
        Academy academy = this.getById(id);
        return Result.success(academy);
    }
}
